﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Windy
{

    public partial class MainForm : Form
    {
        [DllImport("user32.dll", SetLastError = true)]
        static extern UInt32 GetWindowLong(IntPtr hWnd, int nIndex);

        [DllImport("user32.dll")]
        static extern int SetWindowLong(IntPtr hWnd, int nIndex, UInt32 dwNewLong);

        [DllImport("user32.dll")]
        static extern bool SetLayeredWindowAttributes(IntPtr hwnd, uint crKey, byte bAlpha, uint dwFlags);



        private ScreenManager screenManager;

        public MainForm()
        {
            InitializeComponent();
            this.BackColor = Color.Red;
            this.TransparencyKey = Color.Red;

            Debug.WriteLine(string.Format("{0} {0} {2} {1}", 1, 2, 3));
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            var panel = new Panel();
            panel.AutoSize = true;

            int scale = 5;
            foreach (var screen in Screen.AllScreens)
            {
                Debug.WriteLine(screen.Bounds);
                var pnl = new Panel();
                pnl.BackColor = Color.WhiteSmoke;

                pnl.Location = new Point(screen.Bounds.X / scale, screen.Bounds.Y / scale);
                pnl.Size = new Size(screen.Bounds.Width / scale, screen.Bounds.Height / scale);

                panel.Controls.Add(pnl);
            }

            foreach (var btn in panel.Controls)
            {
                var b = btn as Panel;
                if (b.Location.X < 0)
                {
                    var x = b.Location.X;
                    foreach (var b2 in panel.Controls)
                    {
                        var b22 = b2 as Panel;
                        b22.Location = new Point(b22.Location.X + (x * -1));
                    }
                }
            }

            this.Controls.Add(panel);
            panel.Location = new Point(this.Width / 2 - panel.Width / 2, this.Height / 2 - panel.Height / 2);
        }
    }
}
